home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / ghostscript / 8.64 / Resource / Init / gs_icc.ps < prev    next >
Encoding:
Text File  |  2009-04-17  |  3.2 KB  |  94 lines

  1. %    Copyright (C) 2001, 2002 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_icc.ps 8962 2008-08-11 14:16:18Z ken $
  14. % ICCBased color space method dictionaries.
  15. % This assumes gs_ciecs2.ps has already been processed.
  16.  
  17. .currentglobal true .setglobal
  18.  
  19. % gs_res.ps uses these entries in colorspacedict
  20. % to populate the ColorSpaceFamily resource, so we need
  21. % to add the supported spaces.
  22. %
  23. systemdict /colorspacedict get begin
  24. /ICCBased [] def
  25. end
  26.  
  27. NOPSICC { (%END PSICC) .skipeof } if
  28. % Now set up ICC profile loading for PostScript %%BeginICCProfile sections.
  29.  
  30. systemdict begin
  31. /.ProcessICCcomment { % file comment --  file comment
  32.   dup
  33.   (%%BeginICCProfile) anchorsearch {
  34.     pop pop
  35.     DEBUG { (.ProcessICCcomment found %%BeginICCProfile) print flush } if
  36.  
  37.     % load an ICC profile defined as comments (hex encoded).
  38.     % Ends with %%End at the start of a line. Read the data into
  39.     % a bytestring to allow seeking. This string can be used as a
  40.     % seekable ReusableStreamDecode filter source by the ICC logic.
  41.     %
  42.     % Since .bigstring needs to know the size, we first read an array of
  43.     % strings each 64000 max length.
  44.     %
  45.     % stack: --file-- (%%BeginICCProfile: ...) 
  46.     1 index 0 (%%EndICCProfile) /SubFileDecode filter
  47.     [ { counttomark 1 add index
  48.         64000 string readhexstring
  49.         not { exit } if
  50.       } loop
  51.     ] exch closefile
  52.     0 1 index { length add } forall
  53.     .bigstring
  54.     exch 0 exch {
  55.       % stack: --file-- (%%BeginICCProfile: ...) --bytestring-- cur_index --string--
  56.       2 copy length add     % calculate next string start point
  57.       3 1 roll 3 index 3 1 roll putinterval
  58.     } forall
  59.     pop                % discard length of bytestring
  60.     % make a seekable -file- out of the bytestring
  61.     mark /AsyncRead true .dicttomark /ReusableStreamDecode filter
  62.     % stack: --file-- (%%BeginICCProfile: ...) --icc_subfile-- 
  63.     /DeviceCMYK setcolorspace
  64.     << /DataSource 3 -1 roll
  65.        /N 4        % Try CMYK first
  66.     >> { .seticcspace } stopped {
  67.       /DeviceRGB setcolorspace
  68.       dup /N 3 put  { .seticcspace } stopped {
  69.         /DeviceGray setcolorspace
  70.         dup /N 1 put { .seticcspace } stopped {    % last choice
  71.           QUIET not { (   *** Unable to load ICC profile from PostScript DSC comments ***) = flush } if
  72.           pop
  73.         } if
  74.       } if
  75.     } if
  76.   } {
  77.     pop % Not interested in this DSC comment
  78.   } ifelse
  79. } bind def
  80.  
  81. % Merge ProcessICCcomment with existing handler
  82. /.ProcessICCcomment load /exec load
  83. currentuserparams /ProcessDSCComment get 
  84. dup null eq {pop {pop pop}} if /exec load
  85. 4 array astore cvx readonly
  86. << /ProcessDSCComment 3 -1 roll >> setuserparams
  87.  
  88. end    % systemdict
  89. %END PSICC
  90. .setglobal
  91.